import http from "../../utils/http";
Page({
    data: {
        list: []
    },
    getTimeTable() {
        http({
            url: '/student/timetable'
        }).then(res => {
            if (res.code === 0 && res.data) {
                const formattedData = res.data.map(item => {
                    let arr = item.time.split("-");
                    item.times = [];
                    for (let i = 0; i < arr[2]; i++) {
                        item.times.push(arr[0] + "-" + (parseInt(arr[1]) + i));
                    }
                    return item;
                });
                this.setData({
                    list: formattedData
                });
            } else {
                console.error('获取课表失败:', res.message);
            }
        }).catch(err => {
            console.error('网络请求失败:', err);
        });
    },
    onLoad() {
        this.getTimeTable();
    }
});